<include file="Public/header" />
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> 商品管理 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20" style="margin-top:-20px;">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<form class="formleft" name="" id="" action="__URL__/goods/" method="get">
			<input class="input-text" style="width:200px" type="text" value="<{$_GET['goods_no']}>" placeholder="商品编码" name="goods_no">
			<input class="input-text" style="width:200px" type="text" value="<{$_GET['goods_name']}>" placeholder="商品名称" name="goods_name">
			<button type="submit" class="btn btn-success"><i class="icon-plus"></i> 查询</button>
			<a href="javascript:;" onclick="admin_open('添加','__URL__/add_goods/',0,'800','480')" class="btn btn-primary radius"><i class="Hui-iconfont"></i> 添加</a>
			<a href="javascript:;" onclick="importexcelAll()" class="btn btn-primary radius">批量导入</a>
			<a href="javascript:;" onclick="exportExcel()" class="btn btn-primary radius">批量导出</a>
			<a href="javascript:;" onclick="delAll()" class="btn btn-danger radius">批量删除</a>
		</form>
		<span class="r">共有数据：<strong><{$count}></strong> 条</span> 
    </div>
	
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="19">商品列表</th>
			</tr>
			<tr class="text-c">
				<th width="25" class="sorting_disabled" rowspan="1" colspan="1" aria-label="" style="width: 25px;"><input type="checkbox" name="" value=""></th>
				<th>序号</th>
				<th width="">商品名称</th>
				<th width="">商品编码</th>
				<th width="">品牌</th>
				<th width="">型号</th>
				<th width="">规格</th>
				<th width="">缩略图</th>
				<th width="">商品价格</th>
				<th width="">数量</th>
				<th width="">税率(%)</th>
				<th width="">条形码</th>
				<th width="">料号</th>
				<th width="">净重(g)</th>
				<th width="">毛重(g)</th>
				<th width="">添加时间</th>
				<th width="">操作</th>
			</tr>
		</thead>
		<tbody>
			<volist name="list" id="vo">
			<tr class="text-c">
				<td><input type="checkbox" value="<{$vo.id}>" name="" class="ids"></td>
				<td><{$i}></td>
				<td><{$vo.goods_name}></td>
				<td><{$vo.goods_no}></td>
				<td><{$vo.goods_brand}></td>
				<td><{$vo.goods_marque}></td>
				<td><{$vo.goods_spec}></td>
				<td>
				<img src="<{:get_pic($vo['goods_pic'])}>" style="width:51px;cursor:pointer" class="ss" attr_val="1" />
				</td>
				<td><{$vo.price}></td>
				<td><{$vo.receive_amount}></td>
				<td><{$vo.goods_tax}></td>
				<td><{$vo.bar_code}></td>
				<td><{$vo.source_no}></td>
				<td><{:sprintf("%.2f",$vo['net_weight'])}></td>
				<td><{:sprintf("%.2f",$vo['gross_weight'])}></td>
				<td><{$vo.add_time|date="Y-m-d",###}></td>
				<td>
				<a href="javascript:;" onclick="admin_open('编辑','__URL__/edit_goods/id/<{$vo.id}>','<{$vo.id}>','800','480')" class="">编辑</a>
				<a title="删除" href="javascript:;" onclick="admin_del('__URL__/del_goods/','<{$vo.id}>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a>
				</td>
			</tr>
			</volist>			
		</tbody>
	</table>
	<div class="page mt" style="text-align:right"><{$page}></div>
</div>
<script>
	$(function(){
		$(document).on('mousedown','.ss',function(){
			var this_ss=$(this);
			<!-- console.log($(this).attr('src')); -->
			if($(this).attr('attr_val')==1){
				$(this).attr('attr_val',2);
				var index=layer.open({
				  type: 1,
				  shade: false,
				  title: false, //不显示标题
				  closeBtn: 0, //不显示关闭按钮
				  area: ['600px'],
				  content: "<img src="+$(this).attr('src')+" style='width:600px;'/>"
				});
				$(document).on('mousedown','body',function(){
					this_ss.attr('attr_val',1);
					layer.close(index);
				});
			}
		});

	})
	function importexcelAll(id){
        var index=layer.open({
            type: 2,
            title: '导入数据',
            shadeClose: true,
            shade: 0.5,
            area: ['1000px', '150px'],
            content: '__MODULE__/import/importgoods/'+Math.random() //iframe的url
        });
    }
	function exportExcel(){
		var url="<{:U('order/goods',array('excel'=>1))}>/?1=1";
		bar_code=$('input[name=bar_code]').val();
		goods_name=$('input[name=goods_name]').val();
		goods_brand=$('input[name=goods_brand]').val();
		if(bar_code!=""){
			url=url+"&bar_code="+bar_code;
		}
		if(goods_name!=""){
			url=url+"&goods_name="+goods_name;
		}
		if(goods_brand!=""){
			url=url+"&goods_brand="+goods_brand;
		}
		window.location.href=url;
	}
	//批量删除
	function delAll(){
		var option = $(".ids");
		var checked_counts=0;
		var check_val = [];
        for(var i=0;i<option.length;i++){
			if(option[i].checked){
				checked_counts++;
				check_val.push(option[i].value);
			}
		}
		if(checked_counts==0){
			layer.msg('请选择内容');
			return false;
		}else{
			$.ajax({
				type: 'POST',
				data: {ids:check_val},
				url: "<{:U('delAll')}>",
				success:function(data){
					if(data.status==1){	//检查通过，跳转生成波次单页面
						layer.msg(data.info,function(){
							window.location.reload();
						});
					}else{			//检查未通过，刷新页面
						layer.msg(data.info);
					}
					return false;
				}
			})
		}
	}

</script>
<include file="Public/footer" />
<include file="Public/footer_js" />
</body>
</html>